<template>
  <!-- <el-skeleton animated> </el-skeleton> -->
  <div class="box">
    <!-- 面包屑 -->
    <div class="head">
      <el-breadcrumb
        separator-class="el-icon-arrow-right"
        style="line-height: 70px; margin-left: 10px"
      >
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>购物车</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- 全选 -->
    <div class="cart_main">
      <ul class="main_nav">
        <li style="width: 80px; padding-left: 40px">
          <el-checkbox v-model="checked">
            <i style="font-size: 16px">全选</i>
          </el-checkbox>
        </li>
        <li style="width: 300px">商品信息</li>
        <li style="width: 100px">单价</li>
        <li style="width: 150px">数量</li>
        <li style="width: 100px">小计</li>
        <li style="width: 100px">操作</li>
      </ul>

      <ul class="main" ref="">
        <li style="width: 100px">
          <el-checkbox v-model="checked"></el-checkbox>
        </li>
        <li style="width: 300px; text-align: start" class="main_img">
          <img
            src=""
            alt=""
            style="width: 100px; height: 100px; margin-right: 10px"
          />
          <div class="info_box">
            <p class="text"></p>
            <p class="info"></p>
          </div>
        </li>
        <li style="width: 100px">￥{{ price }}</li>
        <li style="width: 150px">
          <el-input-number
            v-model="num"
            @change="handleChange"
            :min="1"
            :max="10"
            size="small"
            label="描述文字"
          ></el-input-number>
        </li>
        <li style="width: 100px; color: #d12424; font-size: 16px">
          ￥{{ nPrice }}
        </li>
        <li style="width: 100px">
          <div class="edit">
            <p>移入收藏夹</p>
            <p class="edit_del" style="color: #27ba9b; margin: 5px 0">
              <el-button type="text" @click="del"
                ><span style="color: #27ba9b">删除</span></el-button
              >
            </p>
            <p>找相似</p>
          </div>
          <!-- 删除弹出框 -->
          <!-- <el-dialog title="温馨提示" :visible.sync="dialogVisible" width="30%">
            <span>亲，您是否确认删除商品</span>
            <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="sureDel">确 定</el-button>
            </span>
          </el-dialog> -->
        </li>
      </ul>

      <!-- 失效商品 -->
      <p class="lose">失效商品</p>
      <ul class="main" ref="">
        <li style="width: 100px">
          <el-checkbox disabled></el-checkbox>
        </li>
        <li style="width: 300px; text-align: start" class="main_img">
          <img
            src=""
            alt=""
            style="width: 100px; height: 100px; margin-right: 10px"
          />
          <div class="info_box">
            <p class="text"></p>
            <p class="info"></p>
          </div>
        </li>
        <li style="width: 100px">￥</li>
        <li style="width: 150px">150</li>
        <li style="width: 100px; color: #d12424; font-size: 16px">￥</li>
        <li style="width: 100px">
          <div class="edit">
            <p class="edit_del" style="color: #27ba9b; margin: 5px 0">
              <el-button type="text" @click="del"
                ><span style="color: #27ba9b">删除</span></el-button
              >
            </p>
            <p>找相似</p>
          </div>
        </li>
      </ul>
    </div>

    <!-- 下单结算 -->
    <div class="center">
      <ul class="cen_left">
        <li style="width: 80px; padding-left: 20px">
          <el-checkbox v-model="checked">
            <i style="font-size: 16px">全选</i>
          </el-checkbox>
        </li>
        <li>删除商品</li>
        <li>移入收藏夹</li>
        <li>清空失效商品</li>
      </ul>

      <ul class="cen_right">
        <li>
          共1件商品，已选择1件商品，商品合计:<span
            style="color: #d12424; font-size: 18px"
            >￥</span
          >
        </li>
        <li>
          <button @click="goOrder">下单结算</button>
        </li>
      </ul>
    </div>
    <!-- 猜你喜欢 -->
    <guessLike>
      <template v-slot:title>
        <p>猜你喜欢</p>
      </template>
    </guessLike>
    <div class="footer"></div>
  </div>
</template>

<script>
import { getCartList } from "../../apis/cart";
// 引入猜你喜欢
import guessLike from "../../components/guessLike.vue";
export default {
  data() {
    return {
      checked: "",
      num: 1,
      cartList: [],
      price: 5,
      nPrice: 5,
      dialogVisible: false,
    };
  },
  methods: {
    handleChange(value) {
      console.log(value);
      this.nPrice = value * this.price;
    },
    // 购物车列表
    async getCart() {
      let res = await getCartList();
      console.log(res);
      this.cartList = res.data.data;
      console.log(this.cartList);
    },
    goOrder() {
      this.$router.push("/order");
    },
    // 删除
    del() {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          // this.$message({
          //   type: "info",
          //   message: "已取消删除",
          // });
        });
    },
    // 确认删除
    sureDel() {
      this.dialogVisible = false;
    },
  },

  components: {
    guessLike,
  },
  created() {
    // this.getCart();
  },
};
</script>

<style lang="scss" scoped>
.box {
  width: 1200px;
  margin: 0 auto;
  // border: 1px solid #000;
  .cart_main {
    background: white;
    // padding: 10px;
    .main_nav {
      // padding: 10px;
      line-height: 70px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      li {
        text-align: center;
        font-size: 16px;
        .el-checkbox {
          display: flex;
          align-items: center;
          ::v-deep .el-checkbox__label {
            padding-left: 3px;
          }
        }
      }
    }
    .main {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 0;
      border-top: 1px solid #eee;
      border-bottom: 1px solid #eee;
      li {
        text-align: center;
      }
      .main_img {
        display: flex;
        align-items: center;
        .info_box {
          width: 190px;
          p {
            line-height: 40px;
            width: 190px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
    .lose {
      font-size: 18px;
      margin-left: 20px;
      line-height: 80px;
    }
  }
  .center {
    margin-top: 20px;
    background: white;
    line-height: 70px;
    align-items: center;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .cen_left {
      display: flex;
      li {
        margin-left: 20px;
        .el-checkbox {
          ::v-deep .el-checkbox__label {
            padding-left: 3px;
          }
        }
      }
    }
    .cen_right {
      display: flex;
      align-items: center;
      button {
        margin: 0 20px;
        width: 160px;
        height: 50px;
        font-size: 16px;
        color: white;
        background: #27ba9b;
        border: none;
        border-radius: 5px;
      }
    }
  }
  // .swiper_box {
  //   background: white;
  //   margin-top: 20px;
  //   .head {
  //     p {
  //       line-height: 80px;
  //       font-size: 24px;
  //     }
  //   }
  //   .swi {
  //     .swi_main {
  //       ul {
  //         display: flex;
  //         justify-content: space-evenly;
  //         li {
  //           text-align: center;
  //           .text{
  //             width: 200px;
  //             overflow: hidden;
  //             text-overflow: ellipsis;
  //             white-space: nowrap;
  //           }
  //         }
  //       }
  //     }
  //   }
  // }
}
</style>